<?php
include_once '../../model/Conexao.php';

$conexao = new Conexao();
$conexao->abrir();
try
{
	$sql1 = "select max(id_ficha) as id_ficha from tb_treino";
	$resultFicha = mysql_query($sql1);
	$rsFicha = mysql_fetch_array($resultFicha);
	
	
	$sql2 = "select * from tb_treino where id_ficha = ".$rsFicha["id_ficha"];
	$resultTreino = mysql_query($sql2);
	if (mysql_error($conexao->getCon())) {
		throw new Exception ();            
	}
} catch (Exception $exc) {
	throw new Exception('Erro!');
}
?>

<html>
	<head>
		<title>Exercício</title>
	</head>
	<script type="text/javascript" language="javascript" src="../FichaExercicio/js/CadastrarFicha.js"></script>
	<body>

		<form name="frm_Exercicio" action="../FichaExercicio/Trata_Cadastro.php" method="post">
			<input type="hidden" name="func" />
			<table border="0">
				<tr>
					<td>
						<!-- Esses valores seram regatados do BD -->
						<label>Tipo de treino</label><br>
						<select name="tipo_treino">
							<option value="0">Selecionar</option>
							<?php
							$cont = 0;
							
							While($rsTreino = mysql_fetch_assoc($resultTreino)) 
							{ 
								$cont = $cont + 1;
								?>
								<option value=<?php echo $rsTreino["id_treino"];?> ><?php echo $rsTreino["observacoes"]; ?></option>
								<?php
							}
							?>							
						</select>
					</td>
				<tr>
					<td>
						<label for="nome_exercicio">Exercicio</label>
						<input type="text" name="nome_exercicio" id="nome_exercicio" />
					</td>
					
					<td>
						<label for="intervalo">Intervalo</label>
						<input type="text" size="5" name="intervalo" id="intervalo" />
					</td>
				</tr>
				<tr>
					<td>
						<label for="num_series">Séries</label>
						<input type="text" size="5" name="num_series" id="num_series" />
					</td>
					<td>
						<label for="num_repeticao">Repetições</label>
						<input type="text" size="10" name="num_repeticao" id="num_repeticao" />
					</td>
				</tr>
				<tr>
					<td>
						<label for="carga">Carga(Kg)</label>
						<input type="text" size="6" name="carga" id="carga" />
					</td>
				</tr>
				<tr>
					<td colspan="5" align="right">
						<button type="button" name="bt_cadastrar" onclick="javascript:cadastrarExercicio('Exercicio')" >Cadastrar</button>
					</td>
				</tr>
			</table>
		</form>
	<body>
</html>